package deom1;

import demo2.*;

import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: LianBao
 * Date: 2024-03-31
 * Time: 10:12
 */
public class Test {
    public static boolean isValid(String s) {
        Stack<Character> stack = new Stack<>();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch == '(' || ch == '{' || ch == '[') {
                stack.push(ch);
            } else {
                //栈空
                if (stack.empty()) {
                    return false;
                }
                //
                char tmp = stack.peek();
                if (tmp == '(' && ch == ')' || tmp == '{' && ch == '}' || tmp == '[' && ch == ']') {
                    stack.pop();
                } else {
                    return false;
                }
            }
        }

        return stack.empty();
    }

    public static void main1(String[] args) {
        String s = "{()";
        System.out.println(isValid(s));
    }

    public static void main(String[] args) {
        arrayQueue queue = new arrayQueue();
        queue.offer(1);
        queue.offer(2);
        int ret = queue.poll();
        System.out.println(queue.peek());
    }

}
